/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/3/3
 * Time:16:26
 **/

@FunctionalInterface
interface NoParameterNoReturn {
    //注意：只能有一个方法
    void test();
}
//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}
//无返回值多个参数
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(int a,int b);
}

//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}

//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}
//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a,int b);
}



public class TestDemo2 {

    public static void main(String[] args) {
        int a = 100;
        NoParameterReturn noParameterReturn = ()->{
            System.out.println(a);
            return 10;
        };
        System.out.println(noParameterReturn.test());
    }

    public static void main2(String[] args) {
        /*NoParameterReturn noParameterReturn = ()->{
            return 10;
        };
        System.out.println(noParameterReturn.test());

        NoParameterReturn noParameterReturn2 = () -> 10;
        System.out.println(noParameterReturn2.test());

        OneParameterReturn oneParameterReturn = (int a)->{
            return a;
        };
        //
        OneParameterReturn oneParameterReturn2 = a -> a;
        oneParameterReturn2.test(10);
*/
        MoreParameterReturn moreParameterReturn = (int a,int b) -> {
            return a+b;
        };
        System.out.println(moreParameterReturn.test(10, 20));

        MoreParameterReturn moreParameterReturn2 = ( a, b) -> a+b;
        System.out.println(moreParameterReturn2.test(10, 20));

    }

    public static void main1(String[] args) {
        NoParameterNoReturn noParameterNoReturn = ()->{
            System.out.println("fasfsda");
        };
        noParameterNoReturn.test();


        OneParameterNoReturn oneParameterNoReturn = (int a)->{
            System.out.println(a);
        };

        oneParameterNoReturn.test(10);

        MoreParameterNoReturn moreParameterNoReturn = (int a,int b) ->{
            System.out.println(a+b);
        };

        moreParameterNoReturn.test(10,20);

    }
}

